package com.example.isoftservice.controller;

import com.example.isoftservice.pojos.Product;
import com.example.isoftservice.service.ProductService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * ClassNmae:ProductController
 * Descriptiopn:
 *
 * @Create 2023/10/27 14:51
 * @Author yidao
 */
@RestController
@CrossOrigin
@RequestMapping("/product")
public class ProductController {
    @Resource
    ProductService productService;

    //查询产品信息
    @RequestMapping( value = "/searchProductInfo",method = RequestMethod.POST)
    public Map<String,Object> searchProductInfo(@RequestBody Product product){
        return productService.searchProductInfo(product);
    }

    //查询大类信息
    @GetMapping( "/searchCategoryInfo")
    public Map<String,Object> searchCategoryInfo(){
        return productService.searchCategoryInfo();
    }

    //删除产品信息
    @RequestMapping(value = "/removeProductById",method = RequestMethod.POST)
    public Map<String,Object> removeProductById(@RequestBody Product product){
        return productService.removeProductById(product);
    }

    //添加产品信息
    @RequestMapping(value = "/addProductInfo",method = RequestMethod.POST)
    public Map<String,Object> addProductInfo(@RequestBody Product product){
        return productService.addProductInfo(product);
    }

    //更新产品信息
    @RequestMapping(value = "/modifyProductInfo",method = RequestMethod.POST)
    public Map<String,Object> modifyProductInfo(@RequestBody Product product){
        return productService.modifyProductById(product);
    }
}
